import request from '@/utils/request'

/**
 * 用户登录
 * post
 * @param {*} data
 */
export function login(data) {
  return request({
    url: '/login',
    method: 'post',
    params: data
  })
}

// 用户注销
export function logout() {
  return request({
    url: '/logout',
    method: 'post'
  })
}

// 通过用户token 获得用户的描述
export function getInfo(token) {
  return request({
    url: '/user/userInfo',
    method: 'get',
    params: { token }
  })
}

export function fetchUser(data) {
  return request({
    url: '/user/list',
    method: 'get',
    params: data
  })
}

export function updateUser(data) {
  return request({
    url: '/user/edit',
    method: 'post',
    params: data
  })
}

export function createUser(data) {
  return request({
    url: '/user/add',
    method: 'post',
    params: data
  })
}

export function deleteUser(params) {
  return request({
    url: '/user/delete',
    method: 'post',
    params
  })
}

export function searchUser(name) {
  return request({
    url: '/user/find',
    method: 'get',
    params: { name }
  })
}

export function findUser(id) {
  return request({
    url: '/user/find',
    method: 'get',
    params: { id }
  })
}
